
package com.bear.net.httpclient;

import java.util.HashMap;


import org.json.JSONException;

import com.bear.net.httpclient.util.NetwrokAssistant;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

/**
 * 通讯请求工具类
 * 
 * @author yinghui.hong
 */
public class RequestUtil {

    private static final String TAG = "RequestUtil";

//    /**
//     * 请求接口
//     * 
//     * @param listener
//     */
//    public static void request(final WebServiceListener listener, String url,
//            HashMap<String, String> valueMap,
//            final Class<? extends ResponseBean> classOfResponseBean) {
//        if (NetwrokAssistant.isNetworkAvailable()) {
//            Handler handler = new Handler() {
//                @Override
//                public void handleMessage(Message msg) {
//                    super.handleMessage(msg);
//                    if (msg.arg1 == HttpResCode.SUCCESS) {
//                        ResponseBean bean = null;
//                        try {
//                            bean = ParseUtil.parseJson2Obj((String) msg.obj, classOfResponseBean);
//                        } catch (JSONException e) {
//                            listener.onResponse(HttpResCode.PARSE_JSON_ERROR, bean);
//                        }
//                        listener.onResponse(HttpResCode.SUCCESS, bean);
//                    } else if (msg.arg1 == HttpResCode.TIME_OUT) {
//                        listener.onResponse(HttpResCode.TIME_OUT, null);
//                    } else if (msg.arg1 == HttpResCode.SERVER_ERROR) {
//                        listener.onResponse(HttpResCode.SERVER_ERROR, null);
//                    }
//                }
//            };
//            HttpRequest.startThreadForPost(url, handler, ParseUtil.parseMap2Str(valueMap));
//        } else {
//            Log.i(TAG, "***********************network is error *************************\n");
//            listener.onResponse(HttpResCode.NETWORK_ERROR, null);
//        }
//    };
}
